$(document).ready(function(){
    $('.content .left, .content input, .content textarea, .content select').focus(function(){
        $(this).parents('.content').addClass("over");
    }).blur(function(){
        $(this).parents('.content').removeClass("over");
    });
    $('.contentA .left, .contentA input, .contentA textarea, .contentA select').focus(function(){
        $(this).parents('.row').addClass("over");
    }).blur(function(){
        $(this).parents('.row').removeClass("over");
    });
});


function createInput(name, value, desc) {
    let doms = []
    doms.push($('<span></span>', {text:desc + ":"}))
    doms.push($('<input>', {name:name, value:value}))
    doms.push($('<br>'))

    return $('<div></div>').append(...doms)
}


function createReqInput(data, name) {
    let doms = []
    doms.push($('<hr>'))
    doms.push($('<div></div>', {text:"请求:" + name, style:"color:red"}))
    doms.push($('<br>'))
    for (let idx in data) {
        doms.push(createInput(idx, data[idx], idx))
    }

    doms.push($('<button></button>', {class:"sc-btn-send", text:"发送", type:"button", target:name}))
    doms.push($('<button></button>', {class:"sc-btn-del", text:"删除", type:"button", target:name}))
    return $('<form></form>').append(...doms)
}


function formToJson(formObj){
    let o = {};
    let a = formObj.serializeArray();
    for (let v of a) {
        o[v.name] = v.value
    }
    return JSON.stringify(o);
}

function FormToJsonObj(formObj){
    let o = {};
    let a = formObj.serializeArray();
    for (let v of a) {
        o[v.name] = v.value
    }
    return o;
}